<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>结构伪类选择器</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
        }

        main {
            padding: 2rem;
            width: 1200px;
            background-color: #EEEEEE;
        }

        main div {
            margin-left: 1rem;
        }

        code {
            padding: 0.25rem 0.5rem;
            margin: 0 4px;
            background-color: rgba(27, 31, 35, .05);
            border-radius: 3px;
        }

        .message {
            font-size: 18px;
            font-weight: bold;
        }

        .content>h2:only-child {
            color: red;
        }
    </style>
</head>

<body>
    <main>
        <h1>结构伪类选择器</h1>
        <p>结构伪类选择器用于选择文档树中的特定结构元素。</p>
        <h2>:only-child</h2>
        <p class="message">选择是唯一子元素的<code>h2</code>标签</p>
        <div class="content">
            <h2>后盾人编程网站</h2>
            <div class="content">
                <h2>后盾人编程网站</h2>
            </div>
        </div>
        <div class="content">
            <h2>后盾人编程网站</h2>
            <aside>
                <h2>后盾人编程网站</h2>
            </aside>
        </div>
    </main>
</body>

</html>